<?php defined('SYSPATH') or die('No direct access allowed.');

	class Jqgrid_Gridmodel{
		
		public $entity_name;
		private $grid_listener;
		
		public function __construct($entity_name,$grid_listener){
			$this->entity_name = $entity_name;
			$this->grid_listener = $grid_listener;
		}
		
		public function getModelData($grid_request,$criteria){
			$grid_request->calculatePages($this->grid_listener->count($criteria));
			$dataset = $this->grid_listener->getList($criteria); //invoco al metodo getList del servicio
			return $grid_request->response($dataset);
		}
		
		public function save($id, array $data){
			return $this->grid_listener->save($id,$data);
		}
		
		public function delete($id){
			return $this->grid_listener->delete($id);
		}
	
	}
?>